package com.fyy.socket.socketServer;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @Author fyy
 * @Description
 * @Date 2020/11/30 15:04
 */
public class MainServer {

    public static void main(String[] args) {
        ServerSocket server = null;
        Socket s = null;

        try {
            server = new ServerSocket (8399);
            System.out.println ("服务器启动，开放端口8399，等待客户端连接......");
            while (true){
                s = server.accept (); //监听,阻塞连接
                System.out.println ("已监听到客户连接到[远程主机" + s.getRemoteSocketAddress()+ ":端口" + s.getPort () + "]");
                new Thread (new SocketServer (s)).start ();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
